package com.one.customer.service;


import com.one.customer.dao.CustomerDao;
import com.one.customer.model.Customer;

public class CurstomerService {
    /** 根据账号密码返回会员信息 — 登录 */
    public Customer login(String username, String password){
        CustomerDao dao = new CustomerDao();
        Customer customer = dao.getCustomerByName(username);
        if(customer != null){
            if (username.equals(customer.getUser_name())&&password.equals(customer.getPassword())){
                return customer;
            }
        }
            return null;
    }

    public boolean register(String username, String password, String phone){
        if (username == null || "".equals(username) || password == null || "".equals(password)){
            return false;
        }
        CustomerDao dao = new CustomerDao();
        //调用Dao层的逻辑进行会员注册
        int result = dao.addCustomer(username, password,phone);
        //返回注册结果：true or false
        return result >0 ;
    }

}
